package com.sjgl.esdn.management.service;

import com.sjgl.esdn.management.entity.FileBrowse;
import com.sjgl.esdn.management.entity.FileDownload;
import com.sjgl.esdn.management.entity.FileManagement;
import com.sjgl.esdn.management.mapper.FileManagementMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class FileManagementService {
    @Autowired
    private FileManagementMapper fileManagementMapper;

    public List<FileManagement> findFileId(Long fileId, int offset, int limit){
        return fileManagementMapper.selectByFileId(fileId,offset,limit);
    }

    public List<FileManagement> fileSearch(String KeyWord, int offset, int limit){
        return fileManagementMapper.fileSearch(KeyWord,offset,limit);
    }

    public List<FileBrowse> fileBrowse(String KeyWord, Long fileId, int offset, int limit){
        List<FileBrowse> list=fileManagementMapper.fileBrowse(KeyWord,fileId,offset,limit);
        for (FileBrowse fileBrowse : list) {
            fileBrowse.setLeaderName("李红");
        }
        return list;
    }

    public List<FileDownload> fileDownload(String KeyWord, Long fileId, int offset, int limit){
        List<FileDownload> list=fileManagementMapper.fileDownload(KeyWord,fileId,offset,limit);
        for (FileDownload fileDownload : list) {
            fileDownload.setLeaderName("李红");
        }
        return list;
    }

    public int updateFileType(Long fileId, String abandonReason,Date abandonTime, Long abandonId){
        return fileManagementMapper.updateFileType(fileId, abandonReason,abandonTime, abandonId);
    }
}
